def handle_response(result_data, code=0):
    if isinstance(result_data, dict):
        result = {'code': code, 'message': 'success', 'data': dict(result_data)}
    elif isinstance(result_data, list):
        result = {'code': code, 'message': 'success', 'data': list(result_data)}
    else:
        result = {'code': code, 'message': 'success', 'data': str(result_data)}
    if code == 1:
        message_failure = {'message': 'failure'}
        result.update(message_failure)
    return result
